package com.train.webadmin.app.model;

import com.baomidou.mybatisplus.annotation.*;
import com.train.common.core.annotation.*;
import lombok.Data;

import java.util.Map;

/**
 * 答题记录实体对象。
 *
 * @author xulei
 * @date 2025-03-07
 */
@Data
@TableName(value = "t_answer_record")
public class TAnswerRecord {

    /**
     * id。
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 历史试卷记录id。
     */
    @TableField(value = "history_paper_id")
    private Long historyPaperId;

    /**
     * 题目id。
     */
    @TableField(value = "question_id")
    private Long questionId;

    /**
     * 用户回答。
     */
    @TableField(value = "user_answer")
    private String userAnswer;

    /**
     * 是否正确。
     */
    @TableField(value = "is_correct")
    private Integer isCorrect;

    /**
     * 题目得分。
     */
    @TableField(value = "score")
    private Double score;

    @RelationOneToOne(
            masterIdField = "historyPaperId",
            slaveModelClass = THistoryPaper.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private THistoryPaper tHistoryPaper;

    @RelationOneToOne(
            masterIdField = "questionId",
            slaveModelClass = TQuestionInfo.class,
            slaveIdField = "id")
    @TableField(exist = false)
    private TQuestionInfo tQuestionInfo;

    @RelationDict(
            masterIdField = "questionId",
            equalOneToOneRelationField = "tQuestionInfo",
            slaveModelClass = TQuestionInfo.class,
            slaveIdField = "id",
            slaveNameField = "title")
    @TableField(exist = false)
    private Map<String, Object> questionIdDictMap;
}
